package com.dyw.ycgovfinance.adapter.list;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dyw.ycgovfinance.R;
import com.dyw.ycgovfinance.bean.NewsListBean;

import java.util.List;

/**
 * Created by clboys on 2017/6/29.
 */

public class ListAdapterForOpenNews extends BaseAdapter {
    private List<NewsListBean> datas;
    private Context context;


    public ListAdapterForOpenNews(List<NewsListBean> datas, Context context) {
        this.datas = datas;
        this.context = context;
    }


    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder myViewHolder = null;
        if (convertView == null) {
            myViewHolder = new MyViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.list_item_open_news, null);
            myViewHolder.tvNewsTime = (TextView) convertView.findViewById(R.id.tv_news_time);
            myViewHolder.tvNewsTitle = (TextView) convertView.findViewById(R.id.tv_news_title);



            convertView.setTag(myViewHolder);
        } else {
            myViewHolder = (MyViewHolder) convertView.getTag();
        }
        NewsListBean newsListBean = datas.get(position);
        myViewHolder.tvNewsTime .setText(newsListBean.getSend_time());
        myViewHolder.tvNewsTitle.setText(newsListBean.getTitle());

        return convertView;
    }


    static class MyViewHolder {
        public TextView tvNewsTime;
        public TextView tvNewsTitle;






    }
}

